package com.it.tz;

import java.util.concurrent.atomic.AtomicInteger;

public class MyRunnable2 implements Runnable {
    // 整数修改的乐观锁：原子类实现的
    private AtomicInteger count = new AtomicInteger(); // 记录浏览人数

    @Override
    public void run() {
        // 100次

        for (int i = 0; i < 100; i++) {
            // count.incrementAndGet() 等价于 ++count
            System.out.println(Thread.currentThread().getName() + "count ======>" + count.incrementAndGet());
        }
    }
}
